package com.lzh.oop.bean;

public class Rectangle {
    Point ptTopLeft;
    Point ptTopRight;
    int width;
    int height;

    Rectangle() {

    }
    public Rectangle(Point topleft, int hight, int width){
        ptTopLeft = topleft;
        this.width = width;
        this.height = hight;
        ptTopRight = new Point(topleft.getX()+width,topleft.getY());
    }

    double perimeter(){
        return 2*(width+height);
    }
    double area(){
        return width*height;
    }
    void draw(){
        System.out.println("绘制矩形");
        System.out.println("左上角坐标："+ptTopLeft.getX()+","+ptTopLeft.getY());
        System.out.println("右上角坐标："+ptTopRight.getX()+","+ptTopRight.getY());
    }
}
